// composables/useInitWebsiteInfo.ts
import { ref, onMounted } from 'vue'
import useWebsiteStore from '@/stores/modules/website'

export function useInitWebsiteInfo() {
  const websiteStore = useWebsiteStore()
  const webInfo = ref(websiteStore.webInfo)
  const loading = ref(true)

  const loadInfo = async () => {
    try {
      const res = await websiteStore.getInfo()
      webInfo.value = res
    } catch (e) {
      console.error('加载网站信息失败', e)
    } finally {
      loading.value = false
    }
  }

  onMounted(() => {
    loadInfo()
  })

  return {
    webInfo,
    loading
  }
}
